<?php

namespace App\Http\Requests;
/**
 * 微信卡券-会员卡等级校验类
 * @package App\Http\Requests
 */
class AdminWxCardMemberLevelPost extends AdminBaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $exceptId = (int) $this->input('id', 0);
        return [
            'card_base_id' => 'required',
            //'key' => 'required|unique:wx_card_member_levels,key,'.$exceptId.',id',
            'key' => 'required',
            'name' => 'required',
            'background_pic_url' => 'required',
            'order_num' => 'integer|min:0',
        ];
    }

    /**
     * 自定义错误消息
     * @return array
     */
    public function messages()
    {
        return [
            'card_base_id.required' => '请指定会员等级所属会员卡',
            'key.required' => '会员等级标识不能为空',
            //'key.unique' => '会员等级标识已存在',
            'name.required' => '会员等级名称不能为空',
            'background_pic_url.required' => '请上传会员卡背景图',
            'order_num.min' => '排序数值必须大于或等于0',
        ];
    }
}
